package com.qf.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.elasticsearch.annotations.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * (Hotal)表实体类
 *
 * @author makejava
 * @since 2020-09-19 18:18:40
 */
@SuppressWarnings("serial")
@Data
@Accessors(chain = true)
@Document(indexName = "hotal_index",shards = 1,replicas = 0)
public class Hotal implements Serializable{
    @TableId(type = IdType.AUTO)
    @Id
    @Excel(name = "酒店id")
    private Integer id;

    @MultiField(
            mainField = @Field(type = FieldType.Text,analyzer = "ik_max_word"),
            otherFields = @InnerField(type = FieldType.Text,analyzer = "pinyin", suffix="pinyin")
    )
    @Excel(name = "酒店名称")
    private String hotalName;

    @Field(type = FieldType.Keyword,index = false)
    private String hotalImage;

    @Field(type = FieldType.Integer)
    @Excel(name = "酒店类型")
    private Integer type;

    @MultiField(
            mainField = @Field(type = FieldType.Text,analyzer = "ik_max_word"),
            otherFields = @InnerField(type = FieldType.Text,analyzer = "pinyin", suffix="pinyin")
    )
    @Excel(name = "酒店信息")
    private String hotalInfo;

    @MultiField(
            mainField = @Field(type = FieldType.Text,analyzer = "ik_max_word"),
            otherFields = {
                    @InnerField(type = FieldType.Text,analyzer = "pinyin", suffix="pinyin"),
                    @InnerField(type = FieldType.Keyword, suffix = "keyword")
            }
    )
    @Excel(name = "关键字")
    private String keyword;

    @Transient
    private double lon;

    @Transient
    private double lat;

    @GeoPointField
    @TableField(exist = false)
    private Double[] location = new Double[2];

    @Field(type = FieldType.Integer)
    @Excel(name = "酒店星级")
    private Integer star;

    @MultiField(
            mainField = @Field(type = FieldType.Text,analyzer = "ik_max_word"),
            otherFields = @InnerField(type = FieldType.Text,analyzer = "pinyin", suffix="pinyin")
    )
    @Excel(name = "酒店品牌")
    private String brand;

    @MultiField(
            mainField = @Field(type = FieldType.Text,analyzer = "ik_max_word"),
            otherFields = @InnerField(type = FieldType.Text,analyzer = "pinyin", suffix="pinyin")
    )
    @Excel(name = "酒店地址")
    private String address;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Field(type = FieldType.Long)
    @Excel(name = "开业时间")
    private Date openTime;

    @Transient
    @Excel(name = "城市id")
    private Integer cid;

    @MultiField(
            mainField = @Field(type = FieldType.Text,analyzer = "ik_max_word"),
            otherFields = @InnerField(type = FieldType.Text,analyzer = "pinyin", suffix="pinyin")
    )
    @Excel(name = "行政区域")
    private String regid;

    @Field(type = FieldType.Nested) //嵌套类型
    @TableField(exist = false)
    private City city = new City();

    @Field(type = FieldType.Nested) //嵌套类型
    @TableField(exist = false)
    private List<Room> rooms = new ArrayList<>();

    @ScriptedField
    @TableField(exist = false)
    private double avgPrice;

    @ScriptedField
    @TableField(exist = false)
    private double distance;


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getHotalName() {
        return hotalName;
    }

    public void setHotalName(String hotalName) {
        this.hotalName = hotalName;
    }

    public String getHotalImage() {
        return hotalImage;
    }

    public void setHotalImage(String hotalImage) {
        this.hotalImage = hotalImage;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getHotalInfo() {
        return hotalInfo;
    }

    public void setHotalInfo(String hotalInfo) {
        this.hotalInfo = hotalInfo;
    }

    public String getKeyword() {
        return keyword;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public double getLon() {
        return lon;
    }

    public Hotal setLon(Double lon) {
        this.lon = lon;
        location[0] = lon;
        return this;
    }

    public double getLat() {
        return lat;
    }

    public Hotal setLat(Double lat) {
        this.lat = lat;
        location[1] = lat;
        return this;
    }

    public Integer getStar() {
        return star;
    }

    public void setStar(Integer star) {
        this.star = star;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Date getOpenTime() {
        return openTime;
    }

    public void setOpenTime(Date openTime) {
        this.openTime = openTime;
    }

    public Integer getCid() {
        return cid;
    }

    public void setCid(Integer cid) {
        this.cid = cid;
    }

    public String getRegid() {
        return regid;
    }

    public void setRegid(String regid) {
        this.regid = regid;
    }
}